#include "../Header/Precompiled.h"
#include "../Header/Sprite.h"
#include "../Header/Graphics.h"
#include "../Header/GameObject.h"



void Sprite::Update(System* system, float frameTime)
{
	Graphics* pGraphics = (Graphics*)system;

	// Compute the scaling matrix

	// Substitute actual object scale if desired
	//Matrix4 transform = Matrix4Scale(2*GetOwner()->GetScale(),2*GetOwner()->GetScale(), 1.0f);
	Matrix4 transform = Matrix4Scale(16.f, 16.f, 1.f);

	// Substitute actual object rotation if desired
	//transform *= Matrix4RotZRad(GetOwner()->Direction);
	transform *= Matrix4RotZRad(0.0f);

	// Compute the translation matrix, concatenate it 
	transform *= Matrix4Translate(parent->getPosition().x,parent->getPosition().y, 0.0f);
	pGraphics->pDevice->SetTransform(D3DTS_WORLD, &transform);
	pGraphics->pDevice->SetTexture(0,pGraphics->Textures[texFilename]);

	// Draw!
	pGraphics->pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
}
